package com.rickpan.dto.request;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

/**
 * 团队消息请求DTO
 */
public class TeamMessageRequest {

    @NotNull(message = "团队ID不能为空")
    private Long teamId;

    @NotBlank(message = "消息内容不能为空")
    @Size(max = 2000, message = "消息内容不能超过2000字符")
    private String content;

    @NotBlank(message = "消息类型不能为空")
    private String messageType = "text"; // text, file, image, emoji

    private String fileName; // 文件消息时使用

    private String fileUrl; // 文件消息时使用

    private Long fileSize; // 文件消息时使用

    private String mimeType; // 文件消息时使用

    private Long replyToId; // 回复消息ID，用于消息回复功能

    // 加密相关字段
    private String iv; // 初始化向量
    private String encryptionAlgorithm; // 加密算法
    private Integer keyVersion; // 密钥版本
    private Boolean isEncrypted; // 是否加密

    // 构造函数
    public TeamMessageRequest() {}

    public TeamMessageRequest(Long teamId, String content, String messageType) {
        this.teamId = teamId;
        this.content = content;
        this.messageType = messageType;
    }

    // Getter 和 Setter 方法
    public Long getTeamId() {
        return teamId;
    }

    public void setTeamId(Long teamId) {
        this.teamId = teamId;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getMessageType() {
        return messageType;
    }

    public void setMessageType(String messageType) {
        this.messageType = messageType;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getFileUrl() {
        return fileUrl;
    }

    public void setFileUrl(String fileUrl) {
        this.fileUrl = fileUrl;
    }

    public Long getFileSize() {
        return fileSize;
    }

    public void setFileSize(Long fileSize) {
        this.fileSize = fileSize;
    }

    public String getMimeType() {
        return mimeType;
    }

    public void setMimeType(String mimeType) {
        this.mimeType = mimeType;
    }

    public Long getReplyToId() {
        return replyToId;
    }

    public void setReplyToId(Long replyToId) {
        this.replyToId = replyToId;
    }

    // 加密字段的getter和setter
    public String getIv() {
        return iv;
    }

    public void setIv(String iv) {
        this.iv = iv;
    }

    public String getEncryptionAlgorithm() {
        return encryptionAlgorithm;
    }

    public void setEncryptionAlgorithm(String encryptionAlgorithm) {
        this.encryptionAlgorithm = encryptionAlgorithm;
    }

    public Integer getKeyVersion() {
        return keyVersion;
    }

    public void setKeyVersion(Integer keyVersion) {
        this.keyVersion = keyVersion;
    }

    public Boolean getIsEncrypted() {
        return isEncrypted;
    }

    public void setIsEncrypted(Boolean isEncrypted) {
        this.isEncrypted = isEncrypted;
    }

    @Override
    public String toString() {
        return "TeamMessageRequest{" +
                "teamId=" + teamId +
                ", content='" + (isEncrypted != null && isEncrypted ? "[ENCRYPTED]" : content) + '\'' +
                ", messageType='" + messageType + '\'' +
                ", fileName='" + (isEncrypted != null && isEncrypted ? "[ENCRYPTED]" : fileName) + '\'' +
                ", fileUrl='" + fileUrl + '\'' +
                ", fileSize=" + fileSize +
                ", mimeType='" + mimeType + '\'' +
                ", replyToId=" + replyToId +
                ", iv='" + (iv != null ? "[PRESENT]" : null) + '\'' +
                ", encryptionAlgorithm='" + encryptionAlgorithm + '\'' +
                ", keyVersion=" + keyVersion +
                ", isEncrypted=" + isEncrypted +
                '}';
    }
}
